package entity;

import state.*;
public class NPCContext {
    private final State[] stateMap = {
            new AngryState(), new SadState(), new SadState(),
            new NormalState(), new NormalState(), new HappyState()
    };
    private State currState;
    private int mood;
    public NPCContext() {
        currState = new NormalState();
        mood = 3;
    }
    public void talkTo(){
        mood += currState.talk();
        changeState();
    }
    public void flatterTo(){
        mood += currState.flatter();
        changeState();
    }
    public void swearTo(){
        mood += currState.swear();
        changeState();
    }
    public void changeEquipmentTo(){
        mood += currState.changeEquipment();
        changeState();
    }
    public void giveGiftTo(){
        mood += currState.giveGift();
        changeState();
    }
    private void changeState(){
        if(mood < 0) mood = 0;
        if(mood > 5) mood = 5;

        currState = stateMap[mood];
        showState();
    }
    private void showState(){
        System.out.println("当前心情："+currState.getClass().getSimpleName());
        System.out.println("心情指数："+mood);
    }
}
